﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
using Comm100.Domain.Entity;
using Newtonsoft.Json;

namespace Bot.Domain.Entities
{
    [Table("t_Chatbot_Webhook")]
    public class Webhook
    {
        [Key]             
        public Guid Id { get; set; }
        public string URL { get; set; }
        public string Header { get; set; }
        [NotMapped]
        public virtual Dictionary<string, string> Headers
        {
            get
            {
                if (!string.IsNullOrEmpty(Header))
                {
                    return JsonConvert.DeserializeObject<Dictionary<string, string>>(Header);
                }

                return new Dictionary<string, string> { };
            }
        }
    }
}
